//
//  WmcHomeImageFilterCell.swift
//  YPWatermarkCamera
//
//  Created by Json on 2023/7/12.
//

import UIKit

class WmcHomeImageFilterCell: WmcBaseCollectionCell {
    
    private lazy var checkView: UIImageView = {
        let imgView = UIImageView()
        imgView.image = "icon_check_44".wmc_image
        return imgView
    }()
    
    var item: WmcImageFilterItem = .init() {
        didSet {
            imageView.image = item.image
            titleLabel.text = item.name
            titleLabel.textColor = item.isSelected ? UIColor.wmc_mainTheme : UIColor.wmc_blackH1_000000
            checkView.isHidden = !item.isSelected
        }
    }
    
    // MARK: UI
    override func makeUI() {
        super.makeUI()
        let imageWH = 44.0.wmc_autoHor
        // imageView
        imageView.contentMode = .scaleAspectFill
        imageView.layer.cornerRadius = imageWH * 0.5
        imageView.clipsToBounds = true
        contentView.addSubview(imageView)
        imageView.snp.makeConstraints { make in
            make.top.equalToSuperview()
            make.width.height.equalTo(imageWH)
            make.centerX.equalToSuperview()
        }
        // checkView
        checkView.layer.cornerRadius = imageWH * 0.5
        checkView.clipsToBounds = true
        contentView.addSubview(checkView)
        checkView.snp.makeConstraints { make in
            make.edges.equalTo(imageView)
        }
        // 名称
        titleLabel.font = 13.wmc_scaleFont()
        titleLabel.textAlignment = .center
        contentView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.left.right.bottom.equalToSuperview()
        }
    }
    
    
}
